package com.CusterRelSys.control;

import com.CusterRelSys.entity.CstCustomer;
import com.CusterRelSys.entity.VOrders;
import com.CusterRelSys.service.CstSustomerWLZService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * Created by wang on 2017/12/1.
 */
@Controller
@RequestMapping("/CstSustomer")
public class CstSustomerWLZControl {
    @Autowired
    CstSustomerWLZService cstSustomerWLZService;

    /*
     *加载客户构成分析表的排序方式
     */
    @RequestMapping("/selectOrderBy")
    public String selectOrderBy(HttpSession session,String type)
    {
        System.out.println("传入的type："+type);
        List<CstCustomer> cstSustomerList=cstSustomerWLZService.selectOrderBy(type);
        for (CstCustomer cstSustomer : cstSustomerList) {
            System.out.println(cstSustomer);
        }
        session.setAttribute("cstSustomerList",cstSustomerList);
        session.setAttribute("type",type);
        return "Views/~rept/cons";
    }


    /*
    *加载客户贡献分析表
    */
    @RequestMapping("/selectContrBy")
    public String selectContrBy(HttpSession session,String odrDate,String odrCustName)
    {
        System.out.println("传入的custName："+odrCustName);
        System.out.println("传入的odrDate："+odrDate);

        VOrders vOrders=new VOrders();
        vOrders.setOdrDate(odrDate);
        vOrders.setOdrCustName(odrCustName);
        List<VOrders> vOrdersList=cstSustomerWLZService.selectContrBy(vOrders);
        for (VOrders vOrderss : vOrdersList) {
            System.out.println(vOrderss);
        }


        session.setAttribute("vOrdersList",vOrdersList);

        return "Views/~rept/contr";
    }
}
